<template>
    <div>
           <el-card>
      <el-button @click="dialogFormVisible = true" type="warning" plain
        >添加分组</el-button
      >

      <el-dialog title="新建分组：" :visible.sync="dialogFormVisible">
        <el-form :model="pushclass">
          <el-form-item label="分组名称：" :label-width="formLabelWidth">
            <el-input v-model="pushclass.name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="分组备注：" :label-width="formLabelWidth">
            <el-input v-model="pushclass.note" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="所属分店：" :label-width="formLabelWidth">
            <el-input v-model="pushclass.subbranch" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogFormVisible = false;btnadd()">确 定</el-button>
        </div>
      </el-dialog>
    </el-card>
    </div>
</template>

<script>
import {addclassPost,getclassPost}from '../../http/api';
export default {
  
    data(){
        return{
       dialogFormVisible: false,
       // 添加分组
      pushclass:{
        name:'',
        note:'',
        subbranch:''
      },
      formLabelWidth: '120px',
        }
    },
 
    methods:{
          // 列表获取函数
      getlist(){
       getclassPost()
        .then((res)=>{
          console.log('接口调用成功',res)
          this.pushclass = res.data.value.data
        })
        .catch((err)=>{
          console.log('接口调用失败',err)
        })
      },
      btnadd(){
        console.log(this.pushclass)
        addclassPost(this.pushclass)
         .then((res)=>{
          console.log('分组添加成功',res)
          this.$parent.getlist()
          
        })
         .catch((err)=>{
          console.log('接口调用失败',err)
        })

      }
      }
    }

</script>